<!DOCTYPE html>
<html lang="zh-cn">
<head>
  <title>$zml.title</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="__PUBLIC__/css/pintuer.css">
  <script src="__PUBLIC__/js/jquery-1.8.3.min.js"></script>
  <script src="__PUBLIC__/js/pintuer.js"></script>
  <script src="__PUBLIC__/js/respond.js"></script>
  <script src="__PUBLIC__/lib/layer/layer.js"></script>
  <script type="text/javascript" src="__PUBLIC__/lib/validform/Validform.min.js"></script>
  <link href="__PUBLIC__/lib/validform/style.css" rel="stylesheet" type="text/css">
</head>
<body>

  <div class="container">
    <div class="x12 padding">

      <form class="form-x" action="#" method="post" autocomplete="off">
		<div class="form-group x6">
			<div class="label padding-right">名称： </div>
			<div class="field">
			  <input type="text" class="input  box-shadow-none radius-none" name="name" value="{$info.name}" />
			</div>
		</div>
		<div class="form-group x6">
			<div class="label padding-right">链接： </div>
			<div class="field">
			  <input type="text" class="input  box-shadow-none radius-none" name="url" value="{$info.url}" />
			</div>
		</div>
       <div class="form-group x6">
			<div class="label padding-right">上级： </div>
			<div class="field">
			  <select class="input box-shadow-none radius-none" name="pid">
				  <option value="0" <if condition="$info.pid eq 0 ">selected</if>>无</option>
				  <volist name="lists" id="vo">
				  <option value="{$vo.id}" <if condition="$info['pid'] eq $vo['id'] ">selected</if>>{$vo.name}</option>
				  </volist>
				</select>
			</div>
		</div>
		<div class="form-group x6">
			<div class="label padding-right">位置： </div>
			<div class="field">
				<select class="input box-shadow-none radius-none" name="type">
				  <option value="0" <if condition="$info['type'] eq '0' ">selected</if>>顶部</option>
				  <option value="1" <if condition="$info['type'] eq '1' ">selected</if>>中间</option>
				  <option value="2" <if condition="$info['type'] eq '2'">selected</if>>底部</option>
				</select>
			</div>
		</div>
		<div class="form-group x6">
			<div class="label padding-right">排序： </div>
			<div class="field">
				<input type="number" min="0" class="input box-shadow-none radius-none" name="sort" value="{$info.sort|default='0'}"  />
			</div>
		</div>
		<div class="form-group x6">
			<div class="label padding-right">状态： </div>
			<div class="field">
				    <label> <input type="radio" name="status" value="1" <if condition="$info['status'] eq '1'">checked</if> /> 正常</label>
					<label> <input type="radio" name="status" value="0" <if condition="$info['status'] eq '0'">checked</if> /> 隐藏</label>

			</div>
		</div>
       
        <div class="margin-big-top text-center">
			<button class="btn button bg-sub" type="button" onclick="save()"> 确 定</button>
        </div>
      </form>

    </div>
  </div>
<script type="text/javascript">
function save(){
	var name=$("input[name='name']");
	var url=$("input[name='url']");
	var sort=$("input[name='sort']");
	var pid=$("select[name='pid']").val();
	var type=$("select[name='type']").val();
	var status=$("input[name='status']:checked").val();
	
	if(name.val().length < 1){
		layer.tips('标题不能为空', name);
		name.focus()
		return false
	}
	if(url.val().length < 1){
		layer.tips('链接地址不能为空', url);
		url.focus()
		return false
	}
      $.ajax({
        type: 'POST',
        url: '__SELF__',
        data: {
          name: name.val(),
          url: url.val(),
          pid: pid,
          sort:sort.val(),
          type:type,
          status:status,
         
        },
        dataType: "json",
        beforeSend: function() {
          layer.load(2, {
            shade: [0.1, '#fff']
          })
        },
        success: function(data) {
          layer.closeAll();
          if (data.status == 1) {
            parent.layer.msg(data.info, {
              shift: 2,
              time: 1000,
              shade: [0.1, '#000'],
              end: function() {
                parent.location.reload()
              }
            })
          } else {
            parent.layer.alert(data.info, {
              icon: 5
            })
          }
        }
      });
  }
   
</script>
</body>
</html>